import java.awt.GridLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.util.TreeMap;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.util.*; 

/**
 * 
 * @author Adam and Terry
 *
 */

public class MapConsole  extends JPanel  {
	
	private TreeMap<String, Area> city;
	private JFrame parent;
	private JCheckBox rail;
	private JCheckBox road;
	private JCheckBox suburb;
	private JComboBox suburbs_combobox;
	
	/**
	 * 
	 * @param city
	 * @param parent
	 */
	public MapConsole(TreeMap<String, Area> city, JFrame parent)
	{
		this.city = city;
		this.parent = parent; 
		this.suburbs_combobox =   new JComboBox();
		this.suburbs_combobox.addItem("All");
		// set the combox values 
	    getJCombox();
		this.setLayout(new GridLayout(1,4,0,0));
		this.add(this.suburbs_combobox); 
		this.add(new JLabel());
		this.add(getCheckBoxOptions());
		this.parent.repaint();
	}
	
	
	/**
	 * 
	 */
	public void getJCombox()
	{
	   Set set = city.entrySet(); 
	   Iterator i = set.iterator(); 
	   while(i.hasNext()) {
			Map.Entry me = (Map.Entry)i.next();
			suburbs_combobox.addItem(me.getKey());
		} 
	}
	
	/**
	 * 
	 * @return panel 
	 */
	
	public JPanel getCheckBoxOptions()
	{
		JPanel panel = new JPanel();
		panel.setLayout(new GridLayout(1,4));
		rail = new JCheckBox("Rail", true);
		road = new JCheckBox("Road", true);
		suburb = new JCheckBox("Suburb", true);
		panel.add(rail);
		panel.add(road);
		panel.add(suburb);
		return panel;
	}
	
	/**
	 * 
	 * @return rail
	 */
	
	public JCheckBox getRail()
	{
		return this.rail;
	}
	
	/**
	 * 
	 * @return surburbs_combobox
	 */
	
	public JComboBox getComboBox()
	{
		return this.suburbs_combobox;
	}
	
	/**
	 * 
	 * @return String 
	 */

	public String getSelectedComboValue()
	{
		 return (String)suburbs_combobox.getSelectedItem();
	}
	
	/**
	 * 
	 * @return road
	 */
	
	public JCheckBox getRoad()
	{
		return this.road;
	}
	
	/**
	 * 
	 * @return suburb
	 */
	public JCheckBox getSuburb()
    {
		return this.suburb;
	}

}
	
